
import os
from loadcase import LoadCase
from multithread import multithread

class DLC(object):
    def __init__(self, dlc_path):
        self.dlc_path = dlc_path
        self.dlc_name = os.path.basename(dlc_path)

        self.loadcases = {}
        for ls in self.__loadcases__():
            self.loadcases.update(ls)

    @property
    def loadcase_groups(self):
        groups=[]
        for p in os.listdir(self.dlc_path):
            real_path = os.path.join(self.dlc_path,p)
            if os.path.isdir(real_path):
                groups.append(real_path)
        return groups

    def __loadcases__(self):
        for lc in self.loadcase_groups:
            yield {os.path.basename(lc):LoadCase(lc)}
        # for rs in multithread(LoadCase, self.loadcase_groups):
        #     yield {rs.lc_name:rs}